<?php

declare(strict_types=1);

namespace App\CustHub\Mapper;

use App\CustHub\Model\ChSeatPackage;
use Hyperf\Database\Model\Builder;
use Hyperf\Database\Model\Collection;
use Hyperf\Database\Model\Model;
use Mine\Abstracts\AbstractMapper;
use Mine\MineModel;

/**
 * 席位套餐
 */
class ChSeatPackageMapper extends AbstractMapper
{
    public function assignModel()
    {
        $this->model = ChSeatPackage::class;
    }

    /**
     * 获取套餐信息
     * @param mixed $id
     * @return ChSeatPackage|Model|Builder|null
     */
    public function findById(mixed $id): ChSeatPackage|Model|Builder|null
    {
        return $this->model::query()
        ->where('id',$id)
        ->first();
    }

    /**
     * 获取席位套餐列表
     * @param int $seatType 0=基础账号 1=互通账号
     * @param int $accountType 0=个人微信 1=企业微信
     * @return array|Collection|\Hyperf\Collection\Collection
     */
    public function getPackageList(int $seatType,int $accountType): array|Collection|\Hyperf\Collection\Collection
    {
        return $this->model::query()
            ->select(['id','name','type','price','original_price'])
            ->where('seat_type',$seatType)
            ->where('account_type',$accountType)
            ->orderBy('sort')
            ->get();
    }
}